<?php

namespace App\Services;

use App\Utils\Sign;

class BaseService{
    public  $appKey;
    public  $appSecret;
    public  $schoolCode;
    public  $subAppid;

    public function __construct()
    {
        $env = ENV;
        $config = self::getConfig();
        if($env){
            $config = $config['real'];
        }else{
            $config = $config['noReal'];
        }
        $this->appKey = $config['app_key'];
        $this->appSecret = $config['app_secret'];
        $this->schoolCode = $config['school_code'];
        $this->subAppid = $config['sub_appid'];
    }

    public function getBaseData(){
        return [
            'school_code' => $this->schoolCode,
            'sub_appid' => $this->subAppid,
            'app_key' => $this->appKey,
            'nonce' => Sign::getNonceStr(),
            'timestamp' => time(),
        ];
    }

    public static function getConfig($tab = ''){

        if($tab){
            $config = require("../config/config.php");
        }else{
            $config = require("config/config.php");
        }
        return $config;
    }


}
